﻿using System;
using System.Web.UI;
using mojoPortal.Web.RS.CRM.AppCode.Lib;


namespace mojoPortal.Web.RS.CRM
{
    public partial class RSAgentDetail : RSBasePage
    {
        int _companyid = 0;
        int _EmployeeID = 0;

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
        }

        protected void Page_Load(object sender, EventArgs e)
        {

            if (!Page.IsPostBack)
            {
                InitializeReadyServicePage();

                RSUserIdentity userIdentity = GetRSUserIdentity();

                if (RSCRMCommonFunctions.ValidatePermission(userIdentity.RSGroupName, userIdentity.RSPIN))
                {
                    if (Request.QueryString["action"] == "add")
                        SetRSPageHeader("Add Agent");
                    else
                        SetRSPageHeader("Edit Agent");

                    _companyid = userIdentity.RSCompanyId;

                    if (!String.IsNullOrEmpty(Request.QueryString["EmployeeID"]))
                        _EmployeeID = Convert.ToInt32(Request.QueryString["EmployeeID"].ToString());

                    if (_companyid > 0)
                    {
                        ucAgentControl.LoadAgentData(_companyid, _EmployeeID);
                    }
                }
                else
                {
                    SetRSPageHeader("");
                    lblMessage.Text = "You Do Not Have Permission To View This Page!";
                    pnlAgent.Visible = false;
                }
            }
        }

    }
}